home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 July / EnigmA AMIGA RUN 20 (1997)(G.R. Edizioni)(IT)[!][issue 1997-07 & 08][EAR-CD IV].iso / earcd / mus / play / splibdev.lha / superplay-lib_DEV / Programmers / Example_SPObjects / ST / SP_SampleListSubs.c < prev    next >
C/C++ Source or Header  |  1997-04-03  |  2KB  |  84 lines

  1. /*
  2. **      $VER: SP_SampleListSubs.c 3.3 (4.1.97)
  3. **
  4. **      SPObject sample list management API
  5. **
  6. **      (C) Copyright 1994-97 Andreas R. Kleinert
  7. **      All Rights Reserved.
  8. */
  9.  
  10. #include "spobject.h"
  11.  
  12.  
  13.  /* SampleList-Support-Functions */
  14.  
  15. struct SPO_SampleList * __saveds __stdargs SPLI_GetSampleList(void);
  16. void                    __saveds __stdargs SPLI_FreeSampleList(struct SPO_SampleList *SampleList);
  17. ULONG                   __saveds __stdargs SPLI_AddSample(struct SPO_SampleList *slist, APTR buffer, ULONG size, ULONG bits, ULONG sps, ULONG volume);
  18.  
  19.  
  20. struct SPO_SampleList * __saveds __stdargs SPLI_GetSampleList(void)
  21. {
  22.  struct SPO_SampleList *SampleList = N;
  23.  struct List           *samelist   = N;
  24.  
  25.  samelist = (struct List *) AllocVec(sizeof(struct SPO_SampleList), MEMF_CLEAR|MEMF_PUBLIC);
  26.  if(samelist)
  27.   {
  28.    SampleList = (APTR) samelist;
  29.  
  30.    SampleList->sl_NumEntries = 0;
  31.  
  32.    samelist->lh_Head     = (struct Node *) &(samelist->lh_Tail);
  33.    samelist->lh_Tail     = N;
  34.    samelist->lh_TailPred = (struct Node *) &(samelist->lh_Head);
  35.    samelist->lh_Type     = NT_UNKNOWN;
  36.   }else return(NULL);
  37.  
  38.  return(SampleList);
  39. }
  40.  
  41. void __saveds __stdargs SPLI_FreeSampleList(struct SPO_SampleList *SampleList)
  42. {
  43.  struct SPO_SampleEntry *entry;
  44.  
  45.  if(SampleList)
  46.   {
  47.    for(entry=(APTR) SampleList->sl_EntryList.lh_Head;(entry)&&(entry!=(APTR) &(SampleList->sl_EntryList.lh_Tail));)
  48.     {
  49.      Remove((APTR) entry);
  50.      FreeVec(entry);
  51.      entry = (APTR) SampleList->sl_EntryList.lh_Head;
  52.     }
  53.  
  54.    FreeVec(SampleList);
  55.   }
  56. }
  57.  
  58. ULONG __saveds __stdargs SPLI_AddSample(struct SPO_SampleList *slist, APTR buffer, ULONG size, ULONG bits, ULONG sps, ULONG volume)
  59. {
  60.  struct SPO_SampleEntry *entry;
  61.  
  62.  entry = (APTR) AllocVec(sizeof(struct SPO_SampleEntry), MEMF_CLEAR|MEMF_PUBLIC);
  63.  if(!entry) return(FALSE);
  64.  
  65.  slist->sl_NumEntries++;
  66.  
  67.  
  68.  entry->se_Version       = 2;
  69.  
  70.  entry->se_Type          = SE_TYPE_SAMPLE;
  71.  
  72.  entry->se_SampleBuffer  = buffer;
  73.  entry->se_SampleSize    = size;
  74.  
  75.  entry->se_SampleBits    = bits;
  76.  entry->se_SamplesPerSec = sps;
  77.  entry->se_Volume        = volume;
  78.  
  79.  
  80.  AddTail((APTR)slist, (APTR)entry);
  81.  
  82.  return(TRUE);
  83. }
  84.